package com.example.ruiji.service.category;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.ruiji.dao.mapper.CategoryMapper;
import com.example.ruiji.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author:BaiYiChen
 * Date:2022/5/1 20:06
 *
 * @author BaiYiChen
 */
@Service
public class CategoryServiceImpl implements CategoryService{
  @Autowired
  private CategoryMapper categoryMapper;
  @Override
  public List<Category> findAllCategory() {
    LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.select(Category::getId,Category::getCategory);
    List list = categoryMapper.selectList(queryWrapper);
    return list;
  }
  
  @Override
  public Category findCategoryById(Integer aId) {
    LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(Category::getId,aId);
    Category category = categoryMapper.selectOne(queryWrapper);
    return category;
  }
  
}
